home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / glibc108.zip / glibc108 / manual / examples / strftim.c < prev    next >
C/C++ Source or Header  |  1994-02-16  |  630b  |  32 lines

  1. #include <time.h>
  2. #include <stdio.h>
  3.  
  4. #define SIZE 256
  5.  
  6. int
  7. main (void)
  8. {
  9.   char buffer[SIZE];
  10.   time_t curtime;
  11.   struct tm *loctime;
  12.  
  13.   /* Get the current time. */
  14.   curtime = time (NULL);
  15.  
  16.   /* Convert it to local time representation. */
  17.   loctime = localtime (&curtime);
  18.  
  19.   /* Print out the date and time in the standard format. */
  20.   fputs (asctime (loctime), stdout);
  21.  
  22. /*@group*/
  23.   /* Print it out in a nice format. */
  24.   strftime (buffer, SIZE, "Today is %A, %B %d.\n", loctime);
  25.   fputs (buffer, stdout);
  26.   strftime (buffer, SIZE, "The time is %I:%M %p.\n", loctime);
  27.   fputs (buffer, stdout);
  28.  
  29.   return 0;
  30. }
  31. /*@end group*/
  32.